<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // Promise.all方法可以传入多个独立的Promise，当所有的Promise都请求成功后，会调用最后的then方法，参数
        // results是一个数组，保存的是所有Promise返回的值
        Promise.all([
            new Promise((resolve)=>{
                setTimeout(() => {
                    resolve(1)
                }, 2000);
            }),
            new Promise((resolve)=>{
                setTimeout(() => {
                    resolve(2)
                }, 1000);
            })
        ]).then(results=>{
            console.log(results)
        })
    </script>
</body>
</html>